#include<stdio.h>
#include<string.h>

int main(){
    FILE *fp=fopen("./test.txt","wb+");
    if(fp==NULL){
        perror("fopen error");
        return -1;
    }
    char* data="你好！！\n";
    fwrite(data,strlen(data),1,fp);
    
    fseek(fp,0,SEEK_SET);

    char buf[1024]={0};
    int ret=fread(buf,1,1023,fp);
    if(ret==0){
        if(ferror(fp)){
            perror("fread error");
            fclose(fp);
            return -1;
        }
        if(feof(fp)){
            printf("end of file!\n");
            fclose(fp);
            return -1;
        }
    }
    printf("%s\n",buf);
    fclose(fp);
    return 0;
}
